#ifndef __DHT11_H__
#define __DHT11_H__

#include <rtthread.h>
#include <rtdevice.h>

#ifdef __cplusplus
extern "C" {
#endif

/* DHT11数据引脚定义 */
#define DHT11_PIN    GET_PIN(0, 4)  // 根据实际连接修改引脚

/* 线程优先级、栈大小和线程控制块定义 */
#define DHT11_THREAD_PRIORITY       29
#define DHT11_THREAD_STACK_SIZE     512
#define DHT11_THREAD_TIMESLICE      5
#define DHT11_period_time           3000

/* 函数声明 */
rt_uint8_t dht11_read_data(rt_uint8_t *temperature, rt_uint8_t *temperature_x,
                           rt_uint8_t *humidity, rt_uint8_t *humidity_x);
void dht11_reset(void);
rt_uint8_t dht11_check(void);
rt_uint8_t dht11_read_bit(void);
rt_uint8_t dht11_read_byte(void);
void dht11_delay_ms(rt_uint32_t ms);
void dht11_delay_us(rt_uint32_t us);

/* 全局变量声明 */
extern rt_uint8_t temperature, temperature_x, humidity, humidity_x;
extern rt_thread_t dht11_thread;

/* 设备初始化函数声明 */
int dht11_device_init(void);

#ifdef __cplusplus
}
#endif

#endif /* __DHT11_H__ */
